//
//  ReallyNameCertifyViewController.m
//  PropertyManager
//
//  Created by TNG on 2018/7/30.
//  Copyright © 2018年 Tng. All rights reserved.
//

#import "ReallyNameCertifyViewController.h"

@interface ReallyNameCertifyViewController () <UITableViewDelegate,UITableViewDataSource>

@property (strong, nonatomic) UITableView * tableview;

@end

@implementation ReallyNameCertifyViewController

static NSString * PropertyReparisInputInfoTableViewCellID = @"PropertyReparisInputInfoTableViewCell";

- (void)viewDidLoad {
    [super viewDidLoad];
    [self.navigationController.navigationBar setHidden:NO];
    self.title = @"实名认证";
    [self creatTableview];
    [self registCell];
}

-(void)registCell
{
    [self.tableview registerClass:[PropertyReparisInputInfoTableViewCell class] forCellReuseIdentifier:PropertyReparisInputInfoTableViewCellID];
}

-(void)creatTableview{
    if (self.tableview == nil) {
        UITableView * tableview = [[UITableView alloc] initWithFrame:CGRectMake(0, kStatusAndNavBarH, WIDTH, HEIGHT - kStatusAndNavBarH - kHomeLineH) style:UITableViewStyleGrouped];
        tableview.delegate = self;
        tableview.dataSource = self;
        tableview.backgroundColor = SFMWhiteColor;
        if (@available(iOS 11.0, *)) {
            tableview.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentAutomatic;
        }
        self.tableview = tableview;
        [self.view addSubview:self.tableview];
    }
}

-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    return 55;
}

-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return 5;
}

-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    PropertyReparisInputInfoTableViewCell * cell = [tableView dequeueReusableCellWithIdentifier:PropertyReparisInputInfoTableViewCellID];
    if (indexPath.row == 0) {
        cell.titleLabel.text = @"真实姓名";
        cell.textfiled.placeholder = @"请输入真实姓名";
    }else if(indexPath.row == 1)
    {
        cell.titleLabel.text = @"联系电话";
        cell.textfiled.placeholder = @"请输入联系电话";
    }else if(indexPath.row == 2)
    {
        cell.titleLabel.text = @"身份证号码";
        cell.textfiled.placeholder = @"请输入身份证号码";
    }else if(indexPath.row == 3)
    {
        cell.titleLabel.text = @"公司名称";
        cell.textfiled.placeholder = @"请输入公司名称";
    }else{
        cell.titleLabel.text = @"服务中心";
        cell.textfiled.placeholder = @"请输入服务中心";
    }
    return cell;
}

-(CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
{
    return 0.01;
}

-(CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section
{
    return 154;
}

-(UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section
{
    return [UIView new];
}

-(UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section
{
    UIView * bgView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, WIDTH, 154)];
    bgView.backgroundColor = SFMWhiteColor;
    
    UIButton * btn = [[UIButton alloc] initWithFrame:CGRectMake(20, 79, WIDTH - 40, 45)];
    btn.layer.cornerRadius = 22.5;
    btn.titleLabel.font = font(16);
    btn.backgroundColor = SFMNavBarColor;
    if(self.isRegist)
    {
        [btn setTitle:@"完成" forState:UIControlStateNormal];
    }else
    {
        [btn setTitle:@"提交" forState:UIControlStateNormal];
    }
    [btn addTarget:self action:@selector(commitBtnClick:) forControlEvents:UIControlEventTouchUpInside];
    [bgView addSubview:btn];
    
    return bgView;
}

#pragma mark - 提交事件
-(void)commitBtnClick:(UIButton *)btn
{
//    if(self.isRegist)
//    {
//        [self dismissViewControllerAnimated:YES completion:nil];
//    }
    RegistViewController * ctr = [[RegistViewController alloc] init];
    [self.navigationController pushViewController:ctr animated:YES];
}

-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    [tableView deselectRowAtIndexPath:indexPath animated:YES];
}

-(BOOL)hidesBottomBarWhenPushed
{
    return YES;
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
